package com.heima.comment.controller.v1;

import com.heima.comment.service.CommentRepayService;
import com.heima.model.comment.dtos.CommentRepayDTO;
import com.heima.model.comment.dtos.CommentRepayLikeDTO;
import com.heima.model.comment.dtos.CommentRepaySaveDTO;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.validator.ValidatorAdd;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(value = "评论回复")
@RestController
@RequestMapping("/api/v1/comment_repay")
public class CommentRepayController {

    @Autowired
    CommentRepayService commentRepayService;

    /**
     * 查看更多回复内容
     * @param dto
     * @return
     */
    @ApiOperation("回复列表")
    @PostMapping("/load")
    public ResponseResult loadCommentRepay( @RequestBody  CommentRepayDTO dto) {
        return commentRepayService.loadCommentRepay(dto);
    }

    /**
     * 保存回复
     * @return
     */
    @ApiOperation("保存回复")
    @PostMapping("/save")
    public ResponseResult saveCommentRepay( @RequestBody  @Validated(ValidatorAdd.class) CommentRepaySaveDTO dto) {
        return commentRepayService.saveCommentRepay(dto);
    }


    /**
     * 点赞回复的评论
     * @param dto
     * @return
     */

    @ApiOperation("点赞回复评论")
    @PostMapping("/like")
    public ResponseResult saveCommentRepayLike( @RequestBody  @Validated(ValidatorAdd.class) CommentRepayLikeDTO dto) {
        return commentRepayService.saveCommentRepayLike(dto);
    }
}
